package org.jshand.cloud.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.jshand.cloud.CustomerBlockHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 金山
 * 项目：sca-all-in-one
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2025/5/2910:30
 */
@RestController
public class RateLimitController {


    @SentinelResource(value = "customerBlockHandlerAndFallback",
            blockHandlerClass = CustomerBlockHandler.class,
            blockHandler = "handleException1",
            fallbackClass = CustomerBlockHandler.class,
            fallback = "handleFallBackException1")

    @GetMapping("/rateLimit/customerBlockHandlerAndFallback/{p1}")
    public String customerBlockHandlerAndFallback(@PathVariable("p1") int p1) {
        if (p1 == 0) {
            throw new RuntimeException("p1参数为0，报错！！！");
        }
        return " customerBlockHandlerAndFallback 程序 正常OK ";
    }
}
